//index.js
//获取应用实例
var app = getApp()
Page({
  data: {
    categoriesList:[]
  },
  addAddess : function () {
    wx.navigateTo({
      url:"../categories/add_categories"
    })
  },
  
  editAddess: function (e) {
    wx.navigateTo({
      url: "../categories/add_categories?id=" + e.currentTarget.dataset.id
    })
  },
  
  onLoad: function () {
    console.log('onLoad')

   
  },
  onShow : function () {

    if(wx.getStorageSync('userid')){
        this.initShippingAddress();
    }else{
      wx.showModal({
        title: '提示',
        content: '请登录！',
        showCancel: true
      })
     
      return
    }
  },
  initShippingAddress: function () {
    var that = this;
    const db = wx.cloud.database()
    db.collection('categories').orderBy('paixu','asc').get({
      success: (res) => {
        if (res.data.length > 0) {
          that.setData({
            categoriesList:res.data
          });
        } else {
          that.setData({
            categoriesList: null
          });
        }
      }
    })
  }

})
